package cn.seqdata.diff;

import java.io.Serializable;

import org.springframework.data.domain.Persistable;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import cn.seqdata.jpa.JpaNamed;

public class JpaJoinValue<ID extends Serializable, L extends JpaNamed<Long>, R extends Persistable<ID>>
		extends JoinValue<ID, L, R> {

	public JpaJoinValue(ID id) {
		super(id);
	}

	public JpaJoinValue(ID id, L left, R right) {
		super(id, left, right);
	}

	public JpaJoinValue(JoinValue<ID, L, R> source) {
		super(source.getId(), source.getLeft(), source.getRight());
	}

	public Long getObject() {
		return null != getLeft() ? getLeft().getId() : null;
	}

	public String getName() {
		return null != getLeft() ? getLeft().getName() : null;
	}

	@JsonIgnore
	@Override
	public L getLeft() {
		return super.getLeft();
	}

	@JsonIgnoreProperties("id")
	@Override
	public R getRight() {
		return super.getRight();
	}
}
